﻿#ifndef CUSTOMTREESTYLE_H
#define CUSTOMTREESTYLE_H

#include <QProxyStyle>
#include <QStyledItemDelegate>

#include "DriverController.h"


// 控件层绘制
class CustomTreeStyle : public QProxyStyle {
public:
    CustomTreeStyle()
        : QProxyStyle() {}

    explicit CustomTreeStyle(QStyle *base)
        : QProxyStyle(base) {}

    void drawPrimitive(PrimitiveElement pe,
                       const QStyleOption *opt,
                       QPainter *p,
                       const QWidget *widget) const override;

    // 扩展分支指示器的尺寸
    int pixelMetric(PixelMetric metric,
                    const QStyleOption *option,
                    const QWidget *widget) const override;
};

// Item节点绘制
class CustomItemDelegate : public QStyledItemDelegate {
public:
    using QStyledItemDelegate::QStyledItemDelegate;

    void paint(QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &index) const override;

    QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override;

    QColor getLampColor(ControlPortType type) const;
};


#endif // CUSTOMTREESTYLE_H
